import { ApiCall } from "tsrpc";
import { ReqRandom_TitleStyle, ResRandom_TitleStyle } from "../../../../shared/master/bag/function/PtlRandom_TitleStyle";
import { player } from "../../../../model/fight/body/player";
import god from "../../../../god";
import app from "../../../../app";
import { Tpl_panel_title, template } from "../../../../shared/master/MsgAction";

export default async function (call: ApiCall<ReqRandom_TitleStyle, ResRandom_TitleStyle>) {
    call.succ({})
    let user = call.req._player as player;
    let res = user.check_wallet(0, 0, [{ id: 'prop-11', v: 1 }], false, '更换称号样式,并且永久增加1点最大生命值💖', true);
    if (!res.state) {
        return;
    }
    user.P.add({Hp_Max:1})
    user.title_style = app.random(1,god.getServerCfgItem('style_title').b).toString();
    let tpl: Tpl_panel_title = {
        style_id: user.style_id,
        style_title_id: user.title_style,
        title_value: user.title_value
    }
    user.sendMsg(template.称号面板,tpl)
}